<?php
/* block title & content */
function portfolio( $atts, $content = null ) {
    extract(shortcode_atts(array(
    ), $atts));
    
    $out = '';
    $count = 0;
    $row = 1;
    
    foreach($atts as $k => $v) {
        
        if($row < 3) {
            if($count == 0) {
                $out .= '<div class="f-left full-width">';                
            }
            
            if($row == 1) {
                if($count == 0) 
                    $out .= '<div class="p-item l img">';
                else
                    $out .= '<div class="p-item r text">';
                     
            } elseif($row == 2) {
                if($count == 0) 
                    $out .= '<div class="p-item r text">';
                else
                    $out .= '<div class="p-item l img">';
            }
            
            if(layout_from_block($k, $v) != false) {
                $out .= layout_from_block($k, $v);
            }

            $out .= '</div>';
            $count ++;
            
            if($count == 2) {
                $out .= '</div>';
                $count = 0;
                $row ++;
            }
        } else {
            if($count == 0) {
                $out .= '<div class="f-left full-width">';                
            }
            
            if($count != 1)
                $out .= '<div class="p-item m img">';
            else
                $out .= '<div class="p-item m text">';
            
            if(layout_from_block($k, $v) != false) {
                $out .= layout_from_block($k, $v);
            }
            
            $out .= '</div>';
            $count ++;
            
            if($count == 3) {
                $out .= '</div>';
                $count = 0;
            }
        }
    }
    
    return $out;
}
add_shortcode('portfolio', 'portfolio');

/* Service box with icon */
function image_frame( $atts, $content = null ) {
    extract(shortcode_atts(array(
	), $atts));
	$output = '
    <div class="image-frame" style="float: '.$atts['align'].';">
        <div style="text-align: '.$atts['align'].';" class="image-frame-inner">
            <img src="'.dynamic_url($atts['img']).'" alt="" />
        </div>
    </div>';
		
	return $output;
}
add_shortcode('image_frame', 'image_frame');
?>